//
//  MYGMeetingsTableViewCell.swift
//  MYDoctor
//
//  Created by 王振明 on 2024/5/8.
//

import UIKit

class MYGMeetingsTableViewCell: UITableViewCell {

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        configUI()
    }
    var model:MYGMeetingListModel = MYGMeetingListModel(){
        didSet{
            if model.roomStartTime.count > 0{
                let startIndex = model.roomStartTime.index(model.roomStartTime.startIndex, offsetBy: 5)
                let endIndex = model.roomStartTime.index(model.roomStartTime.startIndex, offsetBy: 10)
                dateLabel.text = String(model.roomStartTime[startIndex..<endIndex])
            }
            nameLabel.text = model.title
            numLab.text = "共\(model.roomlist.count)条任务"
            fromLabel.text = model.online_offline
        }
    }
    private func configUI(){
        contentView.backgroundColor = .clear
        self.backgroundColor = .clear
        
        contentView.addSubview(whitebackView)
        whitebackView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(76)
            make.top.equalToSuperview().offset(20)
            make.height.equalTo(72.5)
            make.right.equalToSuperview().offset(-19.5)
        }
        contentView.addSubview(dateLabel)
        dateLabel.snp.makeConstraints { make in
            make.left.equalToSuperview()
            make.top.equalToSuperview().offset(20)
            make.height.equalTo(18.5)
            make.right.equalTo(whitebackView.snp.left)
        }
        whitebackView.addSubview(colorView)
        colorView.snp.makeConstraints { make in
            make.left.top.bottom.equalToSuperview()
            make.width.equalTo(4)
        }
        whitebackView.addSubview(nameLabel)
        nameLabel.snp.makeConstraints { make in
            make.left.equalTo(colorView.snp.right).offset(8)
            make.right.equalToSuperview().offset(-72.5)
            make.top.equalToSuperview().offset(9.5)
            make.height.equalTo(18.5)
        }
        whitebackView.addSubview(fromLabel)
        fromLabel.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-11.5)
            make.top.equalToSuperview().offset(13)
            make.height.equalTo(15)
            make.width.equalTo(50)
        }
        whitebackView.addSubview(numLab)
        numLab.snp.makeConstraints { make in
            make.left.equalTo(colorView.snp.right).offset(12)
            make.top.equalTo(nameLabel.snp.bottom).offset(16)
            make.height.equalTo(18.5)
        }
    }
    private lazy var whitebackView:UIView = {
       let cont = UIView()
        cont.backgroundColor = .white
        cont.layer.cornerRadius = 4
        cont.clipsToBounds = true
        cont.layerShadowColor = .rgba(233, 231, 241, 1)
        cont.layerShadowOffset = CGSize(width: 0, height: 2.5)
        cont.layerShadowOpacity = 1
        cont.layerShadowRadius = 7.5
        return cont
    }()
    private lazy var dateLabel: UILabel = {
        let label = UILabel()
        label.textColor = .rgba(51, 51, 51, 1)
        label.font = .medium(13)
        label.text = "09/07"
        label.textAlignment = .center
        return label
    }()
    private lazy var colorView: UIView = {
        let vi = UIView()
        vi.backgroundColor = .rgba(52, 111, 241, 1)
        return vi
    }()
    private lazy var nameLabel: UILabel = {
        let label = UILabel()
        label.textColor = .rgba(51, 51, 51, 1)
        label.font = .medium(13)
        label.text = "关于个人工作台建设方案建设建…"
        return label
    }()
    private lazy var fromLabel: UILabel = {
        let label = UILabel()
        label.textColor = .rgba(255, 255, 255, 1)
        label.font = .medium(9)
//        label.text = "线下会议"
        label.backgroundColor = .rgba(52, 111, 241, 1)
        label.textAlignment = .center
        label.layerCornerRadius = 2.5
        return label
    }()
    private lazy var numLab: UILabel = {
        let label = UILabel()
        label.textColor = .rgba(69, 70, 77, 1)
        label.font = .regular(13)
        label.text = "共7个任务"
        return label
    }()
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
